package flc.ast.adapter;

import android.graphics.Color;
import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.ColorBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.basic.view.container.StkRelativeLayout;

public class ColorAdapter extends StkProviderMultiAdapter<ColorBean> {

    public ColorAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(32));
        addItemProvider(new ColorProvider());
    }

    private class ColorProvider extends BaseItemProvider<ColorBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_color;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, ColorBean bean) {
            if (bean.isSelect()) {
                baseViewHolder.setImageResource(R.id.ivColorItemImg, bean.getSelImg());
            } else {
                baseViewHolder.setImageResource(R.id.ivColorItemImg, bean.getImg());
            }
        }
    }

}
